{% extends 'myhome/person/index.html' %}

{% block css %}
		<title>订单管理</title>

		<!-- <link href="/static/myhome/AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css">
		<link href="/static/myhome/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css"> -->

		<link href="/static/myhome/css/personal.css" rel="stylesheet" type="text/css">
		<link href="/static/myhome/css/orstyle.css" rel="stylesheet" type="text/css">

		<script src="/static/myhome/AmazeUI-2.4.2/assets/js/jquery.min.js"></script>
		<script src="/static/myhome/AmazeUI-2.4.2/assets/js/amazeui.js"></script>
{% endblock %}	

{% block count %}
		
		<div class="center">
			<div class="col-main">
				<div class="main-wrap">

					<div class="user-order">

						<!--标题 -->
						<div class="am-cf am-padding">
							<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">订单管理</strong> / <small>Order</small></div>
						</div>
						<hr/>

						<div class="am-tabs am-tabs-d2 am-margin" data-am-tabs>

							

							<div class="am-tabs-bd">
								
								<div class="am-tab-panel am-fade" id="tab2">

									<div class="order-top">
										<div class="th th-item">
											<td class="td-inner">商品</td>
										</div>
										<div class="th th-price">
											<td class="td-inner">单价</td>
										</div>
										<div class="th th-number">
											<td class="td-inner">数量</td>
										</div>
										<div class="th th-operation">
											<td class="td-inner">商品操作</td>
										</div>
										<div class="th th-amount">
											<td class="td-inner">合计</td>
										</div>
										<div class="th th-status">
											<td class="td-inner">交易状态</td>
										</div>
										<div class="th th-change">
											<td class="td-inner">交易操作</td>
										</div>
									</div>
									
									<div class="order-main" class = 'ododer'>
										<div class="order-list">
											{% for i in uorder %}
											{% for m in i.orderinfo_set.all %}
											<div class="order-status1">
												<div class="order-title">

													<span>下单时间:{{ i.createtime }}</span>
													<!--    <em>店铺：小桔灯</em>-->
												</div>
												<div class="order-content">
													<div class="order-left">
														<ul class="item-list">
															<li class="td td-item">
																<div class="item-pic">
																	<a href="#" class="J_MakePoint">
																		<img src="{{m.gid.g_url}}" class="itempic J_ItemImg">
																	</a>
																</div>
																<div class="item-info">
																	<div class="item-basic-info">
																		<a href="#">
																			<p>{{ m.gid.title }}</p>
																			
																		</a>
																	</div>
																</div>
															</li>
															<li class="td td-price">
																<div class="item-price">
																	{{m.gid.price}}
																</div>
															</li>
															<li class="td td-number">
																<div class="item-number">
																	<span>×</span>{{m.num}}
																</div>
															</li>
															<li class="td td-operation">
																<div class="item-operation">

																</div>
															</li>
														</ul>

														
													</div>
													<div class="order-right">
														<li class="td td-amount">
															<div class="item-amount">
																合计:{{i.total}}
																
															</div>
														</li>
														<!-- <div class="move-right"> -->
															<li class="td td-status">
																<div class="item-status">
																	
																	{% if i.status == 0 %}
																	<p class="Mystatus">未支付</p>
																	<p class="order-info"><a href="javascript:void(0)" rid='{{i.id}}'  class="delod">取消订单</a></p>
																	{% elif i.status == 1 %}
																	<p class="Mystatus">支付成功</p>
																	<p class="order-info"><a href="javascript:void(0)" rid='{{i.id}}'  class="delod">删除订单</a></p>
																	{% endif %}
																	
																</div>
															</li>
															
														<!-- </div> -->
													</div>

												</div>
											</div>
											{% endfor %}
											{% endfor %}

										</div>

									</div>
								
								</div>
								
							</div>

						</div>
					</div>
				</div>

			</div>
			
		</div>
		
		<script type="text/javascript">
			//删除地址
        $('.delod').click(function(){
        	
          var rid = $(this).attr('rid')
          var el = $(this)

          console.log(el)
          // 向后台发送删除的请求
          $.get('{% url "myhome_delorder" %}',{'rid':rid},function(data){

              // 如果成功就删除当前这一行的标签
              if(data['error']==0){
                  alert('删除失败')
              }else if(data['error']==1){
                  // 删除元素
                  alert('删除成功')
                  // el.parents().remove()
                  // el.parentsUntil(".ododer");
                  
              }
          },'json')
        })
        

		</script>
{% endblock %}	
